//
//  DownLoadData.m
//  007AFN的使用
//
//  Created by 黎跃春 on 15/5/18.
//  Copyright (c) 2015年 黎跃春. All rights reserved.
//

#import "DownLoadData.h"
#import "AFAppDotNetAPIClient.h"
#import "NSString+URLEncoding.h"
#import "JokeingModel.h"

@implementation DownLoadData






#pragma mark---下载Joking  music数据
+ (NSURLSessionDataTask *) getRequestType:(RequestType)type withData:(void (^) (id obj, NSError * err))block withPage:(int)page{
    
    NSString * pageSting= nil;
    switch (type) {
        case Enum_JokePage:
            pageSting = [NSString stringWithFormat:JokeUrlString,page];
            break;
        case Enum_MusicPage:
            pageSting = [NSString stringWithFormat:MusicUrtString,page];
            
        default:
            break;
    }


    
    
    return [[AFAppDotNetAPIClient sharedClient]GET:pageSting parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
        if (block) {
            
            NSMutableArray * datas=[NSMutableArray array];
            datas=[responseObject objectForKey:@"list"];
            
            NSMutableArray * applications =[[NSMutableArray alloc]init];
            [datas enumerateObjectsUsingBlock:^(NSDictionary * obz, NSUInteger idx, BOOL *stop) {
                JokeingModel * app = [JokeingModel applicationWithDict:obz];
                [applications addObject:app];
            }];
            
            block(applications,nil);
        }
    } failure:^(NSURLSessionDataTask *task, NSError *error) {
        block(nil,error);
    }];
    
    



}




@end









